Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Prevent rerender when route state did not change #5654

Merged
merged 4 commits into from
Jul 25, 2022

Conversation

dummdidumm
Copy link
Member

Fixes #3732 (and maybe some other issue? Could have sworn I saw something similar about props running in another issue)

No test yet, want to confirm first that this is the right fix

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Jul 21, 2022

🦋 Changeset detected

Latest commit: 9c43a5c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Rich-Harris
Copy link
Member

Ah, interesting. We definitely don't want to re-run load in that case, yeah. That said, there are cases where you do want to trigger a navigation even though nothing changed — think of e.g. you're on / and you click the home icon in the top left, which should cause data to be re-fetched and the scroll to reset.

We need to separate those cases. Related: #2301

@dummdidumm
Copy link
Member Author

True, there's a difference between an implicit update through a session update an an explicit user interaction.
Also related: #2252

@dummdidumm
Copy link
Member Author

dummdidumm commented Jul 22, 2022

I adjusted the code so that only the implicit $session update no longer initiates a rerender and added a test. I also fixed another test which I believe tested the wrong expectation (page store updating on session change, which it shouldn't). Maybe this can also be fixed differently while also fixing #5247 by somehow not telling Svelte to update specific components, will look into that. Edit: Fixing that while removing the code here will bring back the (IMO) wrong page store behavior, so I'm creating another PR for this.

@Rich-Harris Rich-Harris merged commit 8cba6ba into master Jul 25, 2022
@Rich-Harris Rich-Harris deleted the prevent-needless-route-rerender branch July 25, 2022 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

page props are re-set whenever the session store is updated, and the load function is re-run the first time
2 participants